package com.zgm.ch05.aop.before._3_5_2;

import java.lang.reflect.Method;

import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.framework.ProxyFactory;

import com.zgm.ch05.aop._3_2.MessageWriter;

public class SimpleBeforeAdvice implements MethodBeforeAdvice {

	public static void main(String[] args){
		MessageWriter target = new MessageWriter();
		ProxyFactory pf = new ProxyFactory();
		
		pf.addAdvice(new SimpleBeforeAdvice());
		pf.setTarget(target);
		
		MessageWriter proxy = (MessageWriter) pf.getProxy();
		proxy.writeMessage();
		
	}
	
	public void before(Method method, Object[] args, Object target) throws Throwable {
		System.out.println("前置通知：" + method.getName());
		
	}
}
